package o;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.fastengine.fastview.FastSDKEngine;
import com.huawei.fastengine.fastview.startFastappEngine.bean.RpkInfo;
import huawei.widget.HwTextView;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class ead implements ewa {
    private BaseCardBean ˋ;
    private cku ॱ = cku.ˋ(null, null);

    public ead(Context context, BaseCardBean baseCardBean) {
        this.ˋ = baseCardBean;
        View inflate = LayoutInflater.from(context).inflate(h.ـˎ, null);
        int ˎ = ewb.ˎ((Activity) inflate.getContext());
        inflate.setPadding(ˎ, 0, ˎ, 0);
        this.ॱ.ˊ(inflate);
        HwTextView hwTextView = (HwTextView) inflate.findViewById(j.ʻﾟ);
        hwTextView.setText(baseCardBean.ˎͺ());
        if (!ˊ(hwTextView, baseCardBean)) {
            inflate.findViewById(j.ʼʿ).setVisibility(8);
        }
        ((HwTextView) inflate.findViewById(j.ʻﾞ)).setText(baseCardBean.v_());
        ((HwTextView) inflate.findViewById(j.ʼʾ)).setText(baseCardBean.showDetailUrl_);
        eqx.ˏ((ImageView) inflate.findViewById(j.ʻꞌ), baseCardBean.ॱˌ(), "app_default_icon");
        hwTextView = (HwTextView) inflate.findViewById(j.ʼˉ);
        if (baseCardBean.showDisclaimer_ == 1) {
            hwTextView.setText(n.ͺꓸ);
        } else {
            hwTextView.setText(n.ՙˋ);
        }
        this.ॱ.ॱ(-2, context.getString(n.ˊˈ));
        this.ॱ.ॱ(-1, context.getString(n.ॱˈ));
        this.ॱ.setCancelable(false);
        this.ॱ.ˋ((ewa) this);
    }

    public void ॱ(Context context) {
        if (this.ॱ != null && !this.ॱ.isAdded()) {
            this.ॱ.ˋ(context, "h5FastAppDetailDialog");
            if (this.ˋ != null) {
                dzz.ˏ(this.ˋ.showDetailUrl_);
            }
        }
    }

    public void ˏ(Activity activity, DialogInterface dialogInterface, int i) {
        if (i == -1) {
            if (this.ˋ == null) {
                Logger.ˋ("H5FastAppDetailDialog", "cardbean == null");
                return;
            }
            djx.ˊ(this.ˋ.ॱॱ(), activity);
            RpkInfo rpkInfo = new RpkInfo();
            rpkInfo.setPackageName(this.ˋ.ॱـ());
            FastSDKEngine.launchFastAppFromAppGallery(activity, rpkInfo);
            dzz.ˋ(this.ˋ.showDetailUrl_);
        } else if (i == -2) {
            if (cku.ˏ(activity, "h5FastAppDetailDialog")) {
                cku.ˎ((Context) activity, "h5FastAppDetailDialog");
            }
            if (this.ˋ != null) {
                dzz.ॱ(this.ˋ.showDetailUrl_);
            }
        }
    }

    public void ˊ(Activity activity, DialogInterface dialogInterface) {
    }

    private boolean ˊ(HwTextView hwTextView, BaseCardBean baseCardBean) {
        if (hwTextView == null || baseCardBean == null) {
            Logger.ˋ("H5FastAppDetailDialog", "View or data is error.");
            return false;
        } else if (!TextUtils.isEmpty(baseCardBean.ˎͺ())) {
            hwTextView.setText(baseCardBean.ˎͺ());
            return true;
        } else if (TextUtils.isEmpty(baseCardBean.O_())) {
            return false;
        } else {
            hwTextView.setText(baseCardBean.O_());
            return true;
        }
    }
}
